home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / D-G / DinkClass Shareware Package / DC Template App / HLEvents_main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-16  |  2.9 KB  |  141 lines  |  [TEXT/KAHL]

  1. /*
  2.     This is the main function for the DHLEvents application.  This
  3.     file also has the requiered apple event handlers in it.
  4.     Mark Gross 10/10/92
  5. */
  6.  
  7. #include "DHLApp.h"
  8. #include "DHLDoc.h"
  9. #include "DinkUtils.h"
  10.  
  11. //
  12. //Core apple event prototypes
  13. //
  14. void DoAEInstallation(void);
  15.  
  16. pascal OSErr HandleQUIT( AppleEvent *theAppleEvent, AppleEvent *reply,
  17.                          long myRefCon);
  18. pascal OSErr HandleOAPP( AppleEvent *theAppleEvent, AppleEvent *reply, 
  19.                          long myRefCon);
  20. pascal OSErr HandlePDOC( AppleEvent *theAppleEvent, AppleEvent *reply,
  21.                          long myRefCon);
  22. pascal OSErr HandleODOC( AppleEvent *theAppleEvent, AppleEvent *reply,
  23.                          long myRefCon);
  24.  
  25.  
  26. main()
  27. {
  28.     DHLApp    *theApp;
  29.     
  30.     InitToolBox(5);
  31.  
  32.     if(!System7Available() )
  33.         DebugStr( "\p No System 7!!" );
  34.  
  35.     DEventHandler::gApplication = NULL;// to make sure no messages get sent to gApplication 
  36.                                     // before it is instanicated.  otherwise the Application
  37.                                     // object will be sending install handler message to itself
  38.                                     // befor it is fully instaniated.
  39.     
  40.     theApp = new DHLApp;
  41.     
  42.     DEventHandler::gApplication = theApp;
  43.     DEventHandler::gPassItOn = TRUE;
  44.  
  45.     theApp->fCreator = '????';// use your faverate initials
  46.     theApp->fClipType = '????';
  47.     theApp->fMainFileType = '????';
  48.  
  49.     DoAEInstallation();// the AE-handler procs refrence gApplication 
  50.                         // so I'm initializing the AEvents after I have
  51.                         // a valid gApplication
  52.     
  53.     
  54.     if(theApp->InitApp() )
  55.     {            
  56.         theApp->MakeDDoc(FALSE);
  57.         do
  58.         {
  59.             theApp->EventLoop();
  60.         } while(!theApp->CleanUp());
  61.     }
  62.     delete theApp;
  63.     ExitToShell();    //last good bye kiss
  64. }// the end
  65.  
  66.  
  67.  
  68.  
  69.  
  70. void DoAEInstallation(void)
  71. {
  72.  
  73.     AEInstallEventHandler( kCoreEventClass, kAEOpenDocuments,
  74.                             (EventHandlerProcPtr)HandleODOC, 0, false);
  75.  
  76.     AEInstallEventHandler( kCoreEventClass, kAEQuitApplication,
  77.                             (EventHandlerProcPtr)HandleQUIT, 0, false);
  78.  
  79.     AEInstallEventHandler( kCoreEventClass, kAEPrintDocuments,
  80.                             (EventHandlerProcPtr)HandlePDOC, 0, false);
  81.  
  82.     AEInstallEventHandler( kCoreEventClass, kAEOpenApplication,
  83.                             (EventHandlerProcPtr)HandleOAPP, 0, false);
  84.  
  85. }                            
  86.  
  87.  
  88.  
  89. pascal OSErr HandleQUIT( AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon)
  90. {
  91.     OSErr myErr;
  92.     
  93.     myErr = RequiredCheck( theAppleEvent);
  94.     if (myErr) 
  95.         return myErr;
  96.     
  97.     DEventHandler::gApplication->fDone = true;
  98.     return noErr;
  99. }
  100.  
  101.  
  102.  
  103. pascal OSErr HandleOAPP( AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon)
  104. {
  105.     OSErr myErr;
  106.  
  107.     myErr = RequiredCheck( theAppleEvent);
  108.     if (myErr) 
  109.         return myErr;
  110.     
  111.     return noErr;
  112. }
  113.  
  114.  
  115.  
  116. pascal OSErr HandlePDOC( AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon)
  117. {
  118.     OSErr myErr;
  119.  
  120.     myErr = RequiredCheck( theAppleEvent);
  121.     if (myErr) 
  122.         return myErr;
  123.     
  124.     return errAEEventNotHandled;
  125. }
  126.  
  127.  
  128. pascal OSErr HandleODOC( AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon)
  129. {
  130. // this application has no file so ODOC AE will not be of
  131. // much use here.
  132.  
  133.     OSErr myErr;
  134.  
  135.     myErr = RequiredCheck( theAppleEvent);
  136.     if (myErr) 
  137.         return myErr;
  138.     
  139.     return errAEEventNotHandled;
  140. }
  141.